/********************************************************************************
  * @file   : SD93F115B_wwdg.h
  * @author   TEST TEAM 													    	
  * @version  v0															    	
  * @date     Septemper 2022												    	
  * @brief   
  *           
  * Copyright (C) 2022  Hangzhou SDIC Microelectronics Co., Ltd
******************************************************************************/


/* Define to prevent recursive inclusion */
#ifndef __SD93F115B_WWDG_H
#define __SD93F115B_WWDG_H

#ifdef __cplusplus
 extern "C" {
#endif

/********************Includes********************/
#include "SD93F115B.h"


/**************************WWDG_Prescaler****************************/ 
#define WWDG_Prescaler_1    ((uint16_t)0x0000)
#define WWDG_Prescaler_2    ((uint16_t)0x0100)
#define WWDG_Prescaler_4    ((uint16_t)0x0200)
#define WWDG_Prescaler_8    ((uint16_t)0x0300)

#define IS_WWDG_Prescaler(Prescaler) (((Prescaler) == WWDG_Prescaler_1)||((Prescaler) == WWDG_Prescaler_2)||\
                                      ((Prescaler) == WWDG_Prescaler_4)||((Prescaler) == WWDG_Prescaler_8))
									  
									  
typedef struct
{
  uint16_t WWDG_Prescaler; 
  
  uint16_t WWDG_WindowValue;
  
  uint8_t WWDG_Counter;
  
}WWDG_InitTypeDef;

  
#define IS_WWDG_WINDOW_Value(Value) ((Value) >= 0x3F) && ((Value) <= 0x7F))
#define IS_WWDG_Counter(Counter) (((Counter) >= 0x40) && ((Counter) <= 0x7F))

/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
void WWDG_DeInit(void);                                       //将WWDG相关寄存器复位成上电默认值

void WWDG_Init(WWDG_InitTypeDef* WWDG_InitStruct);            //初始化窗口看门狗

void WWDG_SetPrescaler(uint16_t WWDG_Prescaler);              //设置WWDG的预分频器
void WWDG_SetWindowValue(uint16_t WWDG_WindowValue);          //设置WWDG窗口值

void WWDG_SetCounter(uint8_t WWDG_Counter);                   //设置WWDG递减计数值

void WWDG_Cmd(void);                                          //使能WWDG，只能由硬件在复位后清除，使能之前T6位必须被设置为1，以防立即产生一个复位

/* Interrupts and flags management functions **********************************/
void WWDG_ITCmd(void);                                        //使能WWDG的递减计数中断，只能由硬件在复位后清除
ITStatus WWDG_GetITStatus(void);                              //获取WWDG的递减计数中断标志位
void WWDG_ClearITStatus(void);                                //清除WWDG的递减计数中断标志位

#ifdef __cplusplus
}
#endif

#endif /* __SD93F115B_WWDG_H */


/***********************************END OF FILE**************************************/




